home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
COMAL
/
B-Book Series
/
(k)b9.d64
/
proc.link'binary
< prev
next >
Wrap
Text File
|
2007-02-28
|
3KB
|
108 lines
9000 // LINK BINARY PACKAGE
9005 // BY ╩ESSE ╦NIGHT
9010 //
9015 //╘HIS PROCEDURE WILL ALLOW A
9020 //PACKAGE TO BE LINKED FROM WITHIN
9025 //A RUNNING COMAL PROGRAM. ╔T WILL
9030 //ALSO ALLOW A PACKAGE CREATED
9035 //BY AN ASSEMBLER OTHER THAN
9040 //COMMODORE'S TO BE USED.
9045 //
9050 //╞OR A PACKAGE TO BE LINKED
9055 //USING THIS PROCEDURE IT MUST
9060 //BE SAVED AS A BINARY PROGRAM
9065 //FILE. ╘HE LOAD ADDRESS FOR THE
9070 //THE FILE SHOULD GIVE THE
9075 //ADDRESS THE PACKAGE IS TO BE
9080 //LINKED AT.
9085 //
9090 //╘HIS PROCEDURE IS NOT TOTALLY
9095 //IDIOT-PROOF SO PLEASE BE CAREFUL
9100 //WHEN USING IT. ╔T WILL NOT
9105 //ALLOW PACKAGES TO BE LINKED
9110 //BELOW $8009.
9115 //
9120 ╨╥╧├ LINK'BINARY(FILEñNAME$) ├╠╧╙┼─
9125 ╒╙┼ SYSTEM
9130 ─╔═ WORK$ ╧╞ 5
9135
9140 LIBPT:=$C7EF
9145 LIBLO:=$C7F0
9150 LIBHI:=$C7FA
9155 LIBPAG:=$C804
9160
9165 ╔╞ ╨┼┼╦(LIBPT)=10 ╘╚┼╬ ╥┼╨╧╥╘ 76 //TOO MANY LIBRARIES
9170
9175 ╧╨┼╬ ╞╔╠┼ 1,FILEñNAME$+",PRG",╥┼┴─
9180
9185 WORK$:=╟┼╘$(1,5) // LOAD ADDR, PAGE, END ADDR
9190
9195 NEWñPACKñSTART:=╧╥─(WORK$(1:1))+╧╥─(WORK$(2:2))*256
9200 NEWñPAGE:=╧╥─(WORK$(3:3))
9205 NEWñPACKñEND:=╧╥─(WORK$(4:4))+╧╥─(WORK$(5:5))*256
9210
9215 ╔╞ NEWñPAGE>127 ╘╚┼╬ ╥┼╨╧╥╘ 73 //NON-RAM LOAD
9220
9225 ╔╞ NEWñPACKñEND>$BFFF ╘╚┼╬ ╥┼╨╧╥╘ 75 //MEMORY PROTECTED
9230 ╔╞ NEWñPACKñSTART<$8009 ╘╚┼╬
9235 ╨╥╔╬╘ "╔ CAN'T LINK A MODULE BELOW $8009"
9240 ╙╘╧╨
9245 ┼╬─╔╞
9250
9255 ╔╞ ╨┼┼╦(LIBPT)>2 ╘╚┼╬ //AT LEAST ONE PACKAGE IS LINKED
9260
9265 ╞╧╥ PACKAGE#:=2 ╘╧ ╨┼┼╦(LIBPT)-1 ─╧
9270 ERROR:=╘╥╒┼
9275
9280 ╔╞ ╨┼┼╦(LIBPAG+PACKAGE#)>128 ╧╥ MEMñPROTECTED=╞┴╠╙┼ ╘╚┼╬ ERROR:=╞┴╠╙┼
9285
9290 ╔╞ ERROR ╘╚┼╬ ╥┼╨╧╥╘ 75 //MEMORY AREA IS PROTECTED
9295
9300 ┼╬─╞╧╥ PACKAGE#
9305 ┼╬─╔╞
9310
9315 SETPAGE(NEWñPAGE)
9320
9325 ╨╧╦┼ NEWñPACKñSTART,NEWñPAGE
9330 ╨╧╦┼ NEWñPACKñSTART+1,NEWñPACKñEND ═╧─ 256
9335 ╨╧╦┼ NEWñPACKñSTART+2,NEWñPACKñEND ─╔╓ 256
9340
9345 ADDR:=NEWñPACKñSTART+3
9350
9355 ╫╚╔╠┼ ╬╧╘ ┼╧╞(1) ─╧
9360
9365 ╨╧╦┼ ADDR,╧╥─((╟┼╘$(1,1)))
9370 ADDR:+1
9375
9380 ┼╬─╫╚╔╠┼
9385
9390 ├╠╧╙┼ ╞╔╠┼ 1
9395
9400 ╨╧╦┼ LIBLO+╨┼┼╦(LIBPT),NEWñPACKñSTART ═╧─ 256
9405 ╨╧╦┼ LIBHI+╨┼┼╦(LIBPT),NEWñPACKñSTART ─╔╓ 256
9410 ╨╧╦┼ LIBPAG+╨┼┼╦(LIBPT),NEWñPAGE ┬╔╘┴╬─ $E7 //MASK ROMMED BIT
9415 ╨╧╦┼ LIBPT,╨┼┼╦(LIBPT)+1
9420
9425 SENSE:=╨┼┼╦(NEWñPACKñSTART+3)+╨┼┼╦(NEWñPACKñSTART+4)*256
9430 ╨╧╦┼ $C5E8,$4C
9435 ╨╧╦┼ $C5E9,SENSE ═╧─ 256
9440 ╨╧╦┼ $C5EA,SENSE ─╔╓ 256
9445 ╨╧╦┼ $38,2
9450 ╙┘╙ $C5E8 //CALL SENSE WITH FLAG=LINK (2)
9455
9460 ╞╒╬├ PACKñSTART
9465 ╥┼╘╒╥╬ ╨┼┼╦(LIBLO+PACKAGE#)+╨┼┼╦(LIBHI+PACKAGE#)*256
9470 ┼╬─╞╒╬├ PACKñSTART
9475
9480 ╞╒╬├ PACKñEND
9485 SETPAGE(╨┼┼╦(LIBPAG+PACKAGE#))
9490 ╥┼╘╒╥╬ ╨┼┼╦(PACKñSTART+1)+╨┼┼╦(PACKñSTART+2)*256
9495 ┼╬─╞╒╬├ PACKñEND
9500
9505 ╞╒╬├ MEMñPROTECTED
9510 PROTECTED:=╘╥╒┼
9515 ╔╞ NEWñPACKñEND<PACKñSTART ╧╥ NEWñPACKñSTART>PACKñEND ╘╚┼╬ PROTECTED:=╞┴╠╙┼
9520 ╥┼╘╒╥╬ PROTECTED
9525 ┼╬─╞╒╬├ MEMñPROTECTED
9530 ┼╬─╨╥╧├ LINK'BINARY